package com.example.zhaohang.bingzhuangtu;

import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MenuItem;

import com.example.zhaohang.adapter.HandViewAdpter;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class MainActivity extends BaseActivity {

    @InjectView(R.id.drawerlayout)
    DrawerLayout drawerlayout;
    private ActionBarDrawerToggle mToggle;
    private RecyclerView mRecyclerView;

    private List<Object> mList=new ArrayList<>();
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);

        //修改actionBar
        initActonBar();

        initView();

    }

    private void initView() {
        mRecyclerView = (RecyclerView) findViewById(R.id.hand_recycleview);


    }

    private void initActonBar() {

        //修改标题
        ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle("首页");

        //设置箭头
        actionBar.setDefaultDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);


        //设置箭头联动
        mToggle = new ActionBarDrawerToggle(MainActivity.this, drawerlayout, R.string.open, R.string.close);
        //设置同步
        mToggle.syncState();

        //设置箭头监听
        drawerlayout.addDrawerListener(mToggle);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case android.R.id.home:
                mToggle.onOptionsItemSelected(item);
                break;
            default:
        }


        return super.onOptionsItemSelected(item);
    }
    private void initDo() {


        RecyclerView.LayoutManager layout = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true);
        mRecyclerView.setLayoutManager(layout);

        for (int i = 0; i < 50; i++) {
            mList.add("你好" + i);
        }

        mRecyclerView.setAdapter(new HandViewAdpter(mList));
    }
}
